package com.lk.recvice.mq.receive.handler;

import com.lk.recvice.mq.receive.handler.impl.DeviceMqDatasManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class MqManagerBuilder {

	private static MqManagerBuilder instance = new MqManagerBuilder();

	public static MqManagerBuilder getInstance() {
		return instance;
	}


	private Map<String, MqManager> mqManagerRegistry;

	 @Autowired
	 private MqManagerBuilder() {
		 if(mqManagerRegistry == null ) {
			 mqManagerRegistry = new HashMap<>();
		 }
		 mqManagerRegistry.put("device",new DeviceMqDatasManager());

	 }

	 public MqManager build(String handleType) {

		 MqManager manager = mqManagerRegistry.get(handleType);

        if (manager != null) {
            return manager;
        }

        throw new RuntimeException(handleType + ":mq无法识别的处理类型");
	 }

}
